//
//  MYLoginBaseTextPasswordCell.swift
//  MuYing
//
//  Created by tbb on 2019/7/19.
//  Copyright © 2019 TBB. All rights reserved.
//

import UIKit

class MYLoginBaseTextPasswordCell: MYLoginBaseTextFieldCell {

    lazy var safetyBtn: UIButton = {
        let safetyBtn = UIButton(type: .custom);
        safetyBtn.frame = CGRect(x: 0, y: 0, width: 20, height: 30);
        safetyBtn.setImage(UIImage(named: "icon_login_mima_dakai"), for: .normal);
        safetyBtn.setImage(UIImage(named: "icon_login_mima_guanbi"), for: .selected);
        safetyBtn.isSelected = true;
        safetyBtn.addTarget(self, action: #selector(securtyPassword(_:)), for: UIControl.Event.touchUpInside)
        return safetyBtn;
    }()
    
    @objc func securtyPassword(_ sender:UIButton) {
        sender.isSelected = !sender.isSelected;
        textField.isSecureTextEntry = sender.isSelected;
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        self.leftIconImage = UIImage(named: "login_inupt_password_icon");
        textField.rightView = safetyBtn;
        textField.isSecureTextEntry = true;
        textField.rightViewMode = .always;
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

    }

}
